package com.chinasoft.many_to_many;

import com.chinasoft.bean.Student;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface StudentMapper {


    @Select("select distinct s.id ,s.name,s.age from student s, stu_cr sc where sc.sid=sid")
    @Results({
            @Result(column = "id",property = "id"),
            @Result(column = "name" ,property = "name"),
            @Result(column = "age" ,property = "age"),
            @Result(
                    property = "courses",
                    javaType = List.class,
                    column = "id",
                    many = @Many(select = "com.chinasoft.many_to_many.CourcesMapper.selectBySid")
            )
    })
    public List<Student> selectAll();
}